import com.sun.jdi.connect.spi.Connection;

import java.util.*;

class Solution {
    public String convert(String s, int numRows) {
        if(numRows==1) return s;
        int n=s.length();
        StringBuffer sb=new StringBuffer();
        int d=2*numRows-2;
        for(int i=0;i<n;i+=d){
            sb.append(s.charAt(i));
        }
        for(int k=1;k<numRows-1;k++){
            for(int j=k,i=d-k;i<n||j<n;j+=d,i+=d){
                if(j<n) sb.append(s.charAt(j));
                if(i<n)  sb.append(s.charAt(i));

            }
        }
        for(int i=numRows-1;i<n;i+=d){
            sb.append(s.charAt(i));
        }

        return sb.toString();
    }
}
public class SORT {
    public static void main(String[] args) {
        List<Integer> L=new ArrayList<>();
        L.add(1);
        L.add(2);
       Collections.reverse(L);

        int n=4;
        StringBuffer sb = new StringBuffer();
        sb.append("1");
        System.out.println(sb.charAt(0));
    }
    public static void main2(String[] args) {
        String s="PAYPALISHIRING";
        int n=s.length();
        int numRows=3;
        StringBuffer sb=new StringBuffer();
        int d=2*numRows-2;
        for(int i=0;i<n;i+=d){
            sb.append(s.charAt(i));
        }
        for(int k=1;k<numRows-1;k++){
            for(int j=k, i=d-k;i<n||j<n;j+=d,i+=d){
                if(j<n) sb.append(s.charAt(j));
                if(i<n)  sb.append(s.charAt(i));

            }
        }
        for(int i=numRows-1;i<n;i+=d){
            sb.append(s.charAt(i));
        }
    }
    public static void main1(String[] args) {


        int[] nums = {2,0,2,1,1,0};
        int n=nums.length;
        for(int i=1;i<n;i++){
            int tem =nums[i];
            int j=0;
            for(j=i-1;j>=0;j--){
                if(tem<nums[j]){
                    nums[j+1]=nums[j];
                }else{
                    break;
                }

            }
            nums[j+1]=tem;
        }
        for(int i=0;i<n;i++){
            System.out.print(nums[i]+" ");
        }

  for(int i=0;i<n-1;i++){
      for(int j=0;j<n-i-1;j++){
          if(nums[j]>nums[j+1]){
              int temp=nums[j];
              nums[j]=nums[j+1];
              nums[j+1]=temp;
          }
      }
  }
        for(int i=0;i<n;i++){
            System.out.print(nums[i]+" ");
        }
    }
}
